# import sys
import logging


def divisor_fail():
    try:
        1/0
        raise Exception('抛出异常:除数不能为0')
    except (ZeroDivisionError, TypeError, NameError) as err:
        print("error-info:", err)
    else:
        print('try块没有异常,执行else块')
    finally:
        print('不管有没有异常都执行这块')
    return


class MyError(Exception):
    pass


class InputErr(MyError):
    def __init__(self, *args: object) -> None:
        super().__init__(*args)


'''
file = open('./tmp/test.txt', 'w')
file.write()
file.close()
'''


# try语句
def useTryFinally():

    file = open('./tmp/test.txt', 'w')

    try:
        file.write()
    except (Exception) as e:
        logging.info("Reason:", e)
        pass
    finally:
        file.close()


def useWith():
    with open('./tmp/test.txt', 'w') as f:
        f.write()


divisor_fail()
